//
//  ViewController.swift
//  SQliteData
//
//  Created by Henry LIU on 16/12/2014.
//  Copyright (c) 2014 Henry LIU. All rights reserved.
//

import UIKit


class ViewController: UIViewController {

    @IBOutlet var txtRollNo: UITextField!
    
    @IBOutlet var txtName: UITextField!
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    @IBAction func btnInsertClicked(sender: AnyObject) {
        var studentInfo: StudentInfo = StudentInfo()
        studentInfo.studentRollNo = txtRollNo.text
        studentInfo.studentName = txtName.text
        var isInserted = ModelManager.instance.addStudentData(studentInfo)
        if isInserted {
            Utils.invokeAlertMethod("", strBody: "Record Inserted successfully", delegate: nil)
        }else{
            Utils.invokeAlertMethod("", strBody: "Error in inserting record", delegate: nil)
        }
        txtRollNo.text = ""
        txtName.text = ""
        txtRollNo.becomeFirstResponder()
        
        ModelManager.instance.getAllStudnentData();
    }
    
    
    @IBAction func btnUpdateClicked(sender: AnyObject) {
    }
    
    
    @IBAction func btnDeleteClicked(sender: AnyObject) {
    }
    
    
}

